﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using KaartenLib;

namespace WindowsFormsApplication1
{    

    public partial class Login : Form
    {
        private Speler speler;

        private ErrorForm error;

        public Login()
        {
            InitializeComponent();
        }

        public Login(ref Speler speler): this()
        {
            this.speler = speler;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if(this.NaamTextBox.Text.Length <=2){
                    String text = "Je naam moet minstens 3 letters bevatten!";
                    if (error == null)
                    {
                        error = new ErrorForm();
                    }
                    error.changeText(text);                    
                }else if (this.NaamTextBox.Text.Contains("0") ||
                        this.NaamTextBox.Text.Contains("1") ||
                        this.NaamTextBox.Text.Contains("2") ||
                        this.NaamTextBox.Text.Contains("3") ||
                        this.NaamTextBox.Text.Contains("4") ||
                        this.NaamTextBox.Text.Contains("5") ||
                        this.NaamTextBox.Text.Contains("6") ||
                        this.NaamTextBox.Text.Contains("7") ||
                        this.NaamTextBox.Text.Contains("8") ||
                        this.NaamTextBox.Text.Contains("9")
                        )
                    {
                        String text = "Naam mag geen getal bevatten!";
                        ErrorForm error = new ErrorForm();
                        error.changeText(text);                        
                    }
                 else{
                    speler.Naam = this.NaamTextBox.Text;
                    speler.BeginPunten = (int)this.PuntenBox.Value;
                    if (error != null)
                    {
                        error.Dispose();
                    }
                    this.Hide();
                }
            }
            catch (ArgumentException ex) { }
            //InzetFormulier form = new InzetFormulier(ref speler);
            //form.Show();
        }
    }
}
